<template>
<!-- 产品列表组件 -->
    <ul>
        <li v-for="item in productsListData" :key="item.id" @click="goToDetail(item.id)">
            <img v-lazy="item.list_pic_url" style="display:block;" width="100%" alt="" />
            <div class="van-ellipsis">{{item.name}}</div>
            <div class="price">{{item.retail_price | RMBFormat}}</div>
        </li>
    </ul>
</template>

<script>
export default {
    props:["productsListData"],
    data () {
        return {
            // imgSrc:require("@/assets/logo.png")
 
        }
    },
    methods:{
        goToDetail(id){
            this.$router.push("/productdetail?id="+id);
            // 解决 跳转到当前所在路由的时候，不进行跳转的问题
            if(this.$route.path=="/productdetail"){
                // 刷新页面
                setTimeout(()=>{
                    this.$router.go(0);
                 
                },100)
                
            }
            
        }
    }
}
</script>
 
<style lang = "less" scoped>
ul{
    padding: .1rem 2%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    li{
        width: 49%;
        margin-bottom: .1rem;
        background: #fff;
        text-align: center;
        line-height: .3rem;
        .price{
            color: darkred;
        }
    }
}
</style>